home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 November & December / Amiga-CD 1997 #11-12.iso / pd-disketten / ungepackt / 9_95 / apd-9-95-2 / arexx-workshop / listings / lhacontrol next >
Text File  |  1996-01-25  |  11KB  |  314 lines

  1. /* LHAControl written 04.94 by Karsten Wysocki */
  2.  
  3. call addlib("rexxsupport.library",0,-30,0)
  4. call addlib("apig.library",0,-30,0)
  5.  
  6. call SET_APIG_GLOBALS()
  7.  
  8. portname = "LHAControl"
  9. portlist = Showlist('p')
  10. if find(portlist,portname) > 0 then exit
  11. p = openport(portname)
  12.  
  13. request = "freq = ALLOCFILEREQUEST();
  14.            filename = REQUESTFILE(freq,multi,save,hail,dir,file,0,nofile,
  15.                                   null(),-10,-2,200,211,'222022'x);
  16.            call FREEFILEREQUEST(freq);
  17.            pos = index(filename,'/');
  18.            if pos = 0 then pos = index(filename,':');
  19.               else do;
  20.                      do forever;
  21.                      newpos = index(filename,'/',pos+1);
  22.                      if newpos > 0 then pos = newpos;
  23.                      else leave;
  24.                      end;
  25.                    end;
  26.            dir  = left(filename,pos);
  27.            file = delstr(filename,1,pos);"
  28.  
  29. TRUE  = 1
  30. FALSE = 0
  31.  
  32. LH5 = " -2"
  33. LH4 = " -1"
  34. LH1 = " -0"
  35.  
  36. recoursiv = " -r"
  37. emptydirs = " -e"
  38. paths     = " -x"
  39. touch     = " -E"
  40. newfiles  = " -G"
  41.  
  42. archiv   = "a"
  43. freshen  = "f"
  44. extract  = "e"
  45. fullpath = "x"
  46.  
  47. archivswitches = recoursiv || emptydirs || LH5
  48. archivcommand = archiv
  49. extractswitches = ""
  50. extractcommand = fullpath
  51.  
  52. multi   = 1
  53. arcdir  = "SYS:"
  54. extdir  = "RAM:"
  55. nofile  = FALSE
  56. filename = ""
  57.  
  58. archive  = 10
  59. extract  = 20
  60. contents = 30
  61. options  = 40
  62.  
  63. scr          = LOCKPUBSCREEN("Workbench")
  64. scrvinfo     = GETVISUALINFO(scr)
  65. scrfont      = GETVALUE(scr,40,4,'p')
  66. glistpointer = ALLOCVEC(4,MEMF_CLEAR)
  67. conxgad      = CREATECONTEXT(glistpointer)
  68. previousgadget = conxgad
  69.  
  70. makegadget = "call SETNEWGADGET(newgadx,scrvinfo,scrfont,lft,top,wdt,hgt,
  71.                                 gadname,PLACETEXT_IN,gadnr,null());
  72.               previousgadget = CREATEGADGET(BUTTON_KIND,previousgadget,
  73.                                             newgadx,TAG_DONE,0)"
  74.  
  75. gadname = "Archive"
  76. gadnr   =  archive
  77. lft     = 3
  78. top     = 3
  79. wdt     = 92
  80. hgt     = 12
  81. newgadx = MAKENEWGADGET(scrvinfo,scrfont,lft,top,wdt,hgt,gadname,
  82.                         ,PLACETEXT_IN,gadnr,null())
  83. previousgadget = CREATEGADGET(BUTTON_KIND,previousgadget,newgadx,TAG_DONE,0)
  84.  
  85. gadname = "Extract"
  86. gadnr   =  extract
  87. lft     =  97
  88. interpret makegadget
  89.  
  90. gadname = "Contents"
  91. gadnr   =  contents
  92. lft     = 3
  93. top     = 18
  94. interpret makegadget
  95.  
  96. gadname = "Options"
  97. gadnr   =  options
  98. lft     =  97
  99. interpret makegadget
  100.  
  101.  
  102. wintitle = "LHA Control"
  103. winidcmp = CLOSEWINDOW+GADGETUP+GADGETDOWN+MOUSEMOVE
  104. winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+GIMMEZEROZERO+ACTIVATE
  105.  
  106. w1  = OPENWINDOW(portname,0,211,200,45,2,4,winidcmp,winflags,wintitle,
  107.                  ,scr,0,null(),null(),conxgad)
  108. call GT_REFRESHWINDOW(w1,null())
  109. rpw1 = GETWINDOWRASTPORT(w1)
  110.  
  111.  
  112. exitme = 0
  113. do forever
  114.    x = waitpkt(portname)
  115.    do forever
  116.       msg = getpkt(portname)
  117.       if msg = '0000 0000'x then leave
  118.       msgclass  = getarg(msg,0)
  119.       optmsg = delstr(msgclass,11)
  120.       if optmsg = "LHAOptions" then
  121.          do
  122.            optmsg = delstr(msgclass,1,11)
  123.            if optmsg ~= "END"
  124.               then do
  125.                    opts = optmsg
  126.                    trenn = index(opts,'|')
  127.                    extractswitches = delstr(opts,trenn)
  128.                    opts = delstr(opts,1,trenn)
  129.                    trenn = index(opts,'|')
  130.                    extractcommand = delstr(opts,trenn)
  131.                    opts = delstr(opts,1,trenn)
  132.                    trenn = index(opts,'|')
  133.                    archivswitches = delstr(opts,trenn)
  134.                    opts = delstr(opts,1,trenn)
  135.                    archivcommand = opts
  136.                    end
  137.          end
  138.       if msgclass = DIE then exitme = 1
  139.       if msgclass = CLOSEWINDOW then exitme = 1
  140.       if msgclass = GADGETUP then
  141.          do
  142.            gadid  = getarg(msg,9)
  143.            select
  144.                  when gadid = archive then
  145.                       do
  146.                       multi = 1
  147.                       save = FALSE
  148.                       nofile = FALSE
  149.                       file = "#?";dir = arcdir
  150.                       hail = "Select Dir or File(s) to archive"
  151.                       interpret request
  152.                       if filename ~= null()
  153.                          then do
  154.                               arcdir = dir
  155.                               filespec = '22'x || filename || '22'x
  156.                               dirinfo = (delstr(dir,length(dir))) || '.info'
  157.                           if exists(dirinfo)
  158.                              then filespec = filespec || '2022'x || dirinfo || '22'x
  159.                               multi = 0
  160.                               save = TRUE
  161.                               nofile = FALSE
  162.                               file = "";dir = "RAM:"
  163.                               hail = "Select Archive-Dir and Filename"
  164.                               interpret request
  165.                               if file ~= "" & filename ~= null()
  166.                                  then do
  167.                                       call archive()
  168.                                       end
  169.                                  else do
  170.                                       call noarchive()
  171.                                       end
  172.                               end
  173.                       end
  174.                  when gadid = extract then
  175.                       do
  176.                         multi = 0
  177.                         save = FALSE
  178.                         nofile = FALSE
  179.                         file = ""; dir = extdir
  180.                         hail = "Select Archive to extract"
  181.                         interpret request
  182.                         if filename ~= null() & file ~= ""
  183.                            then do
  184.                                 archivname = filename;archivout = compress(archivname)
  185.                                 extdir = dir
  186.                                 x = easyrequest(w1,"LHA Control Request",
  187.                                                ,'Extract to 'extdir'?',
  188.                                                ,'Yes|Filerequester|Cancel')
  189.                                 if x = 2
  190.                                    then do
  191.                                         multi = 0
  192.                                         save = TRUE
  193.                                         nofile = FALSE
  194.                                         file = ""; dir = extdir
  195.                                         hail = "Select Dir to extract Archive"
  196.                                         interpret request
  197.                                         if filename ~= null()
  198.                                            then do
  199.                                                 call extract()
  200.                                                 end
  201.                                         end
  202.                                  if x = 1 then call extractcurrent()
  203.                                 end
  204.                       end
  205.                  when gadid = contents then
  206.                       do
  207.                         multi = 0
  208.                         save = FALSE
  209.                         nofile = FALSE
  210.                         file = ""; dir = "RAM:"
  211.                         hail = "Select Archive to list contents"
  212.                         interpret request
  213.                         if filename ~= null() & file ~= ""
  214.                            then do
  215.                                 call contents()
  216.                                 end
  217.                       end
  218.                  when gadid = options then
  219.                       do
  220.                         portlist = Showlist('p')
  221.                         if find(portlist,"LHAOptions") = 0
  222.                            then do
  223.                                 opts = extractswitches '|' extractcommand '|' archivswitches '|' archivcommand
  224.                                 call setclip('LHAopts',opts)
  225.                                 ADDRESS COMMAND 'run >NIL: rx LHAOptions'
  226.                                 end
  227.                       end
  228.                  otherwise nop
  229.            end
  230.          end
  231.       x = reply(msg,0)
  232.    end
  233.    if exitme = 1 then leave
  234. end
  235.  
  236. call CLOSEWINDOW(w1)
  237. call UNLOCKPUBSCREEN(null(),scr)
  238. call FREEVISUALINFO(scrvinfo)
  239. call FREEGADGETS(conxgad)
  240. call FREETHIS(newgadx)
  241. call FREEVEC(glistpointer)
  242.  
  243. portlist = Showlist('p')
  244. if find(portlist,"LHAOptions") > 0 then ADDRESS 'LHAOptions' DIE
  245.  
  246. exit
  247.  
  248.  
  249.  
  250.  
  251.  
  252. /*-------------------------------------------------------------------------*/
  253. /*                    Unterprogramm archive                                */
  254. /*-------------------------------------------------------------------------*/
  255.  
  256. archive:
  257.    archivname = filename
  258.     archivout = compress(archivname)
  259.             x = 'run lha >CON:0/9/600/101/ARCHIVE...'archivout'.lha(lzh)/AUTO/WAIT '
  260.   lha_archive = x || archivswitches archivcommand '22'x || archivname || '22'x filespec
  261.   address command lha_archive
  262. return
  263.  
  264.  
  265.  
  266.  
  267. /*-------------------------------------------------------------------------*/
  268. /*                    Unterprogramm noarchive                              */
  269. /*-------------------------------------------------------------------------*/
  270.  
  271. noarchive:
  272.   x = easyrequest(w1,"LHA Control Request",'No Archive-name given, operation canceled','OK')
  273. return
  274.  
  275.  
  276.  
  277.  
  278. /*-------------------------------------------------------------------------*/
  279. /*                    Unterprogramm extract                                */
  280. /*-------------------------------------------------------------------------*/
  281.  
  282. extract:
  283.        extdir = dir
  284.     extdirout = compress(extdir)
  285.             x = 'run lha >CON:0/110/600/101/EXTRACT...'archivout'>>>'extdirout'/AUTO/WAIT '
  286.   lha_extract = x || extractswitches extractcommand '22'x || archivname || '222022'x || extdir || '22'x
  287.   address command lha_extract
  288. return
  289.  
  290.  
  291.  
  292.  
  293. /*-------------------------------------------------------------------------*/
  294. /*                    Unterprogramm extractcurrent                         */
  295. /*-------------------------------------------------------------------------*/
  296.  
  297. extractcurrent:
  298.             x = 'run lha >CON:0/110/600/101/EXTRACT...'archivout'/AUTO/WAIT '
  299.     lha_excur = x || extractswitches extractcommand '22'x || archivname || '222022'x || extdir || '22'x
  300.     address command lha_excur
  301. return
  302.  
  303.  
  304.  
  305. /*-------------------------------------------------------------------------*/
  306. /*                    Unterprogramm contents                               */
  307. /*-------------------------------------------------------------------------*/
  308.  
  309. contents:
  310.     archivout = compress(filename)
  311.             x = 'run lha >CON:0/9/600/202/ARCHIVECONTENTS...'archivout'/AUTO/WAIT v '
  312.     lha_conts = x || '22'x || filename || '22'x
  313.     address command lha_conts
  314. return